<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/11/22
  Time: 9:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
  <title>产品列表</title>
  <meta http-equiv="Content-Language" content="zh-cn">
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

  <style>
    body{
      background: rgba(0, 0, 0, 0.7);
      background-attachment: fixed;
    }
    .container .row .illu{
      background: rgba(0, 0, 0, 0.7);
      height:250px;
      border-radius: 25px;
      color:#0391BC;
    }
    .container .row dl{
      margin-top: 10px
    }
    .container .row dl dt{
      font-family: "微软雅黑";
      font-size: 30px;
    }
    .container .row dl dd{
      font-family: "宋体";
      font-size: 15px;
      line-height: 28px;
      font-weight: bold;
    }
    .container .row dl ul {
      list-style: none;
    }
    @media (min-width:768px) {
      .col-sm-6 {
        margin-left: 20px;
        margin-bottom: 30px;
        width: 45%;
      }
    }
    @media (min-width: 992px) {
      .col-md-4 {
        margin-left: 20px;
        margin-bottom: 30px;
        float: left;
        width: 30%;
      }
    }
    @media (min-width: 1200px) {
      .col-lg-3 {
        margin-left: 20px;
        margin-bottom: 30px;
        width:23%;
      }
      .container .row .col-lg-3 dl dd{
        line-height: 20px;
      }
    }

    /*main样式结束*/

    /*栏目管理样式开始 column*/
    .pos{
      height: 35px;
      font-size: 14px;
      border-bottom:1px solid;
      color: #EFEFF5;
      font-weight: bold;
    }
    .icoh{
      margin-top: 5px;
      display:inline-block;
      width:20px;
      height: 20px;
      line-height: 23px;
    }
    .operate{
      color: #10DDE8;
    }
    .operate .list .tablewrap table .table{
      border:none;

    }

    /*栏目管理样式结束column*/

    /*introduce 公司介绍开始*/

    .line{
      margin:0 10px;
    }
    /*introduce 公司介绍结束*/
    .intro .col-sm-2{
      color:#fff;
      line-height: 210px;
      font-size: 35px;
    }
    .intro .fill{
      height:50px;
    }

    /*网站设置*/
    .iframecontent{
      color: #10DDE8;
    }
    li{
      list-style: none
    }
    input,textarea{
      color:#000;
    }

    .itab ul li {
      float: left;
      margin-right: 5px;
      border: 1px solid #DCE3ED;
      background: #EAEEF4;

    }
    .itab ul li.current-item {
      border-top: 1px solid #DCE3ED;
      border-left: 1px solid #DCE3ED;
      border-right: 1px solid #DCE3ED;
      border-bottom: 1px solid #fff;
      background: #fff;
    }
    .itab ul li a {
      display: block;
      font-size: 14px;
      color: #10DDE8;
      padding: 2px 10px;
    }
    .itab ul li.current-item a {
      font-weight: bold;
    }
    .itabcontent dl {
      margin: 20px 0;
    }
    .itabcontent dl dt {
      width: 12%;
      float: left;
      font-size: 14px;
    }
    .itabcontent dl dt.surebtn {
      text-indent: -9999px;
    }
    .itabcontent dl dd {
      width: 600px;
      float: left;
    }
    .itabcontent dl dd input[type="text"] {
      width: 300px;
    }
    .itabcontent dl dd input[type="radio"] {
      vertical-align: top;
    }
    .A1{position: relative;
      left: 83%;
      top: -3px;
    }
    .A2{
      position: relative;
      left: 20%;
      top: 0px;
    }
    .A3{position: relative;
      left: 30%;
      top: 0px;}
  </style>
</head>
<body>
<div class="iframecontent">
  <div class="pos">
    <i class="icoh"></i>
    <span>商品管理</span>
    <a class="A1" href="${pageContext.request.contextPath}/addUIProduct.do">
      <input type="button" value="添加商品" style="width: 111px">
    </a>
  </div>
      <table class="table" width="100%" id="datalist">
          <div class="row">
            <c:forEach var="pg" items="${p}">
              <div class="col-xs-2"><%--框架--%>
                <div class="thumbnail" style="background-color: inherit;"><%--图片--%>
                  <img src="${pageContext.request.contextPath}/${pg.image}" alt="..." style="height: 16%">
                  <div class=""><%--文字--%>
                    <h5 style="overflow: hidden;text-overflow:ellipsis;white-space: nowrap">${pg.pname}</h5>
                    <p>市场价：${pg["market_price"]}</p>
                    <p>是否热销：
                      <c:if test="${pg[\"is_hot\"] eq 1}">是</c:if><%--eq：相等--%>
                      <c:if test="${pg[\"is_hot\"] eq 0}">否</c:if>
                    </p>
                    <p class="A2">
                      <a href="${pageContext.request.contextPath}/editUIProduct.do?pid=${pg.pid}">
                        <input type="button" name="" value="修改" class="btn btn-primary">
                      </a>
                      <a href="${pageContext.request.contextPath}/deleteProduct.do?pid=${pg.pid}" onclick="return confirm('确认是否删除')" class="btn btn-danger" role="button">删除
                      </a>
                    </p>
                  </div>
                </div>
              </div>
            </c:forEach>
          </div>
        <hr>
        <div CLASS="A3">
          <%--页码处理--%>
          <c:choose>
            <%--当显示页码时,总页码<=10时，全部显示--%>
            <c:when test="${pageInfo.pages<=10}">
              <c:set var="begin" value="1"/>
              <c:set var="end" value="${pageInfo.pages}"/>
            </c:when>
            <%--当总页码>10时,只显示10页--%>
            <c:otherwise>
              <c:set var="begin" value="${pageInfo.pageNum-5}"/>
              <c:set var="end" value="${pageInfo.pageNum+4}"/>
              <%--当前页-5后的begin<1时：begin=1, end=10--%>
              <c:if test="${begin<1}">
                <c:set var="begin" value="1"/>
                <c:set var="end" value="10"/>
              </c:if>
              <%--当前页+4后的end>总页数时:begin=总页数-9,end=总页数--%>
              <c:if test="${end>pageInfo.pages}">
                <c:set var="begin" value="${pageInfo.pages-9}"/>
                <c:set var="end" value="${pageInfo.pages}"/>
              </c:if>
            </c:otherwise>
          </c:choose>
          <%--样式及显示--%>
          <nav aria-label="...">

            <ul class="pagination">
              <li><a href="${pageContext.request.contextPath}/findAllProduct.do?page=1">首页</a></li>

              <%--上一页--%>
              <c:if test="${pageInfo.pageNum>1}">
                <li class="">
                  <a href="${pageContext.request.contextPath}/findAllProduct.do?page=${pageInfo.pageNum-1}" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span></a>
                </li>
              </c:if>

              <%--<li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>--%>
              <c:forEach var="num" begin="${begin}" end="${end}">
                <%--显示页码时，是当前页，则不显示超链接--%>
                <c:choose>
                  <c:when test="${num==pageInfo.pageNum}"><%--ne:不等于--%>
                    <li class="active">
                      <span>${num}<span class="sr-only">(current)</span></span><%--a标签改为span标签--%>
                    </li>
                  </c:when>
                  <c:otherwise>
                    <li class="">
                      <a href="${pageContext.request.contextPath}/findAllProduct.do?page=${num}">${num} <span class="sr-only">(current)</span></a>
                    </li>
                  </c:otherwise>
                </c:choose>
              </c:forEach>

              <%--当前页面为最后一页时不显示下一页--%>
              <c:if test="${pageInfo.pageNum<pageInfo.pages}">
                <li>
                  <a href="${pageContext.request.contextPath}/findAllProduct.do?page=${pageInfo.pageNum+1}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                  </a>
                </li>
              </c:if>

              <li><a href="${pageContext.request.contextPath}/findAllProduct.do?page=${pageInfo.pages}">尾页</a></li>
            </ul>
          </nav>
        </div s >
      </table>
  </div>
</body>
</html>